/**
 * @see https://umijs.org/zh-CN/plugins/plugin-access
 * */
let accessData = {};
const handleaccessData = function (data: any) {
  accessData = data;
};
export { handleaccessData };
export default function access(initialState: any) {
  console.log('加载完毕');
  console.log(initialState);
  const { userMenusKeys = [] } = initialState;

  return {
    ...accessData,
    ...{
      normalRouteFilter: (route: any) => {
        // console.log(route);
        return userMenusKeys.includes(route.key);
      },
      canAdd: (route: any) => {
        // console.log(route);
        return accessData[route.key]['新增 '];
      },
    },
  };
}
